package com.mg.jsfapp.singleton;

import java.io.Serializable;


public class DemoSingleton implements Serializable {
   private static final long serialVersionUID = 1L;

   private DemoSingleton() {
       if (DemoSingletonHolder.INSTANCE != null) {
          throw new RuntimeException("already instantiated");
       }
   }

   private static class DemoSingletonHolder {
       public static final DemoSingleton INSTANCE = new DemoSingleton();
   }

   public static DemoSingleton getInstance() {
       return DemoSingletonHolder.INSTANCE;
   }

   protected Object readResolve() {
       return getInstance();
   }
}